package br.com.fogas.webservice.repository.soap;

import android.content.Context;
import br.com.fogas.utils.exception.ParseXmlException;
import br.com.fogas.webservice.exception.ERaiseWebServiceException;
import br.com.fogas.webservice.exception.RespostaWebServiceException;
import br.com.fogas.webservice.exception.SemConexaoInternetException;
import br.com.fogas.webservice.exception.ServidorForaException;
import br.com.fogas.webservice.exception.TempoEsperaRespostaException;
import br.com.fogas.webservice.exception.WebServiceException;
import br.com.fogas.webservice.parser.config.ConfigEnvelope;
import br.com.fogas.webservice.parser.config.ConfigRequest;
import br.com.fogas.webservice.parser.config.ConfigResponse;
import br.com.fogas.webservice.repository.IRepositoryHandler;
import br.com.fogas.webservice.soap.impl.ConfigSOAP;

public class ConfigRepository implements IRepositoryHandler<ConfigResponse> {

	private Context context;
	
	private ConfigRequest request;

	public ConfigRepository(Context context, ConfigRequest request) {
		this.context = context;
		this.request = request;
	}
	
	@Override
	public ConfigResponse getResponse() throws SemConexaoInternetException,
			ParseXmlException, TempoEsperaRespostaException,
			ServidorForaException, RespostaWebServiceException,
			WebServiceException, ERaiseWebServiceException {
		ConfigEnvelope envelope = new ConfigEnvelope();
		envelope.body.configRequest = request;

		ConfigSOAP soap = new ConfigSOAP(context, envelope);
		return soap.getResponse();
	}

}
